package com.ninong.ker.log.rest;

import com.ninong.ker.log.service.FwLogService;
import com.ninong.ker.log.service.dto.FwLogDTO;
import com.ninong.ker.common.tools.enums.BusinessEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


import com.ninong.ker.common.annotation.log.Log;
import com.ninong.ker.common.annotation.perm.CmdAdmin;
import com.ninong.ker.common.response.CmdResponse;


/**
 * 系统日志
 *
 * @author 鸠摩智
 * @email dongmingchao@pian-ai.com
 * @date 2021-02-04 13:46:43
 */
@RestController
@RequestMapping("/cmd/log")
public class FwLogResouces {

    @Autowired
    private FwLogService fwLogService;

    /**
     * 列表
     */
    @Log("日志列表")
    @CmdAdmin({"admin", "log:list"})
    @PostMapping(value = "/resouce")
    public ResponseEntity<CmdResponse> list(@RequestBody FwLogDTO dto) {
        CmdResponse response = new CmdResponse();
        response.setData(fwLogService.listPage(dto));
        return ResponseEntity.ok(response);
    }


    @Log("日志删除")
    @CmdAdmin({"admin", "log:delete"})
    @DeleteMapping(value = "/resouce")
    public ResponseEntity<CmdResponse> delete(@RequestBody String[] ids) {
        fwLogService.delete(ids);
        CmdResponse response = new CmdResponse();
        response.setMessage(BusinessEnum.DELETE_SUCCESS.getMsg());
        return ResponseEntity.ok(response);
    }
}
